package com.penghaisoft.microwms.product.service.impl;

import com.penghaisoft.microwms.common.data.model.ProSellOutSn;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.product.dao.ProSellOutSnMapper;
import com.penghaisoft.microwms.product.service.IProSellOutSnService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 业务逻辑实现类
 * </p>
 * 
 * @author
 * @createDate 
 **/
@Service("proSellOutSnService")
public class ProSellOutSnServiceImpl extends BaseService implements IProSellOutSnService{
		@Resource
		private ProSellOutSnMapper proSellOutSnMapper;
		
	  /**
	   * 新增记录
	   * @param proSellOutSn
	   * @return
	   */
		@Override
		public Resp create(ProSellOutSn proSellOutSn){
			proSellOutSnMapper.create(proSellOutSn);
			return success();
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param proSellOutSn
	   * @return
	   */
		@Override
		public Resp delete(ProSellOutSn proSellOutSn){
			proSellOutSnMapper.delete(proSellOutSn);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param page,rows
	   * @param condition
	   * @return
	   */
		@Override
		public Pager<ProSellOutSn> findListByCondition(int page, int rows, ProSellOutSn condition){
		    Pager<ProSellOutSn> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
    		condition.preQuery();
    		long size = proSellOutSnMapper.queryCount(condition);
    		List<ProSellOutSn> records = new ArrayList<>();
    		if(size > 0){
    			records = proSellOutSnMapper.queryList(pager,condition);
    		}
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public ProSellOutSn findById(String id){
			return proSellOutSnMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param proSellOutSn
	   * @return
	   */
		@Override
		public Resp update(ProSellOutSn proSellOutSn){
			proSellOutSnMapper.updateBySelect(proSellOutSn);
			return success();
		}

	@Override
	public List<ProSellOutSn> findByAny(ProSellOutSn proSellOutSn) {
		return proSellOutSnMapper.queryByAny(proSellOutSn);
	}

	@Override
	public Long queryCount(ProSellOutSn proSellOutSn) {
		return proSellOutSnMapper.queryCount(proSellOutSn);
	}

}
